package com.cloudminga.gui;


import com.globussoft.xml.SettingsXml;
//import com.pomblast.persistentlayer.User;
import java.awt.Dimension;
import java.awt.Toolkit;
import javax.swing.JRadioButton;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Gui_2.java
 *
 * Created on Dec 17, 2009, 11:59:00 AM
 */

/**
 *
 * @author jyoti
 */
public class Config_2_setting extends javax.swing.JDialog {

 public static boolean encryptpombit = false,encryptpersonbit = false;
 private String projectName="";

    /** Creates new form Gui_2 */
    public Config_2_setting(java.awt.Frame parent, boolean modal) {

        super(parent, modal);
         Dimension dimension = new Dimension(600, 500);
        initComponents();
        setSize(600, 500);
        projectName=SettingsXml.getProjectName();
        this.setTitle("Welcome to "+projectName+" Backup Wizard Configuration");
        RadioButton_448bit.setText("Encript my data with  "+projectName+" 448 bit .");
        Toolkit toolkit = Toolkit.getDefaultToolkit();
        int x = (toolkit.getScreenSize().width - getWidth()) / 2;
        int y = (toolkit.getScreenSize().height - getHeight()) / 2;
        setResizable(true);
        setLocation(x, y);
        setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
                    
      //  RadioButton_256bit.setSelected(true);
        String s="<html>"+
                "<body>"+
                "<font size=3 color=black>Select one of the following"+
                "<br>"+
                "encription method for securing"+
                "<br>"+
                "your data."+
                "</font>"+
                "</body>"+
                "</html>";
        label2.setText(s);

        try {
            /* code to set the look and feel according to the native operating system */

            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
            SwingUtilities.updateComponentTreeUI(this);

        } catch (Exception e) {
            System.out.println("Problem in setting look and feel");
        }
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        backEncryptButton = new javax.swing.JButton();
        cancelEncryptButton = new javax.swing.JButton();
        nextEncryptButton = new javax.swing.JButton();
        RadioButton_448bit = new javax.swing.JRadioButton();
        RadioButton_256bit = new javax.swing.JRadioButton();
        label_image = new javax.swing.JLabel();
        jPanel1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        label_Logo = new javax.swing.JLabel();
        label2 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("");
        setResizable(false);
        getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        backEncryptButton.setText("Back");
        backEncryptButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                backEncryptButtonActionPerformed(evt);
            }
        });
        getContentPane().add(backEncryptButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(300, 410, 60, -1));

        cancelEncryptButton.setText("Cancel");
        cancelEncryptButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cancelEncryptButtonActionPerformed(evt);
            }
        });
        getContentPane().add(cancelEncryptButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(440, 410, -1, -1));

        nextEncryptButton.setText("Next ");
        nextEncryptButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                nextEncryptButtonActionPerformed(evt);
            }
        });
        getContentPane().add(nextEncryptButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(370, 410, -1, -1));

        RadioButton_448bit.setLabel("");
        RadioButton_448bit.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                RadioButton_448bitActionPerformed(evt);
            }
        });
        getContentPane().add(RadioButton_448bit, new org.netbeans.lib.awtextra.AbsoluteConstraints(280, 230, 270, -1));

        RadioButton_256bit.setSelected(true);
        RadioButton_256bit.setText("Encript my data with my personal 256's bit.");
        RadioButton_256bit.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                RadioButton_256bitActionPerformed(evt);
            }
        });
        getContentPane().add(RadioButton_256bit, new org.netbeans.lib.awtextra.AbsoluteConstraints(280, 260, -1, -1));

        label_image.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/config_2_setting.jpg"))); // NOI18N
        getContentPane().add(label_image, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 90, 230, 310));

        jPanel1.setBackground(new java.awt.Color(204, 204, 204));
        jPanel1.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jLabel1.setFont(new java.awt.Font("Arial", 0, 18));
        jLabel1.setForeground(new java.awt.Color(51, 51, 255));
        jLabel1.setText("Encryption Settings");
        jPanel1.add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 10, -1, -1));
        jPanel1.add(jLabel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(480, 10, 60, -1));

        label_Logo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/logo_2.png"))); // NOI18N
        jPanel1.add(label_Logo, new org.netbeans.lib.awtextra.AbsoluteConstraints(500, 10, 50, 50));

        getContentPane().add(jPanel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, 560, 70));
        getContentPane().add(label2, new org.netbeans.lib.awtextra.AbsoluteConstraints(290, 110, -1, 50));

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void RadioButton_448bitActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_RadioButton_448bitActionPerformed
        // TODO add your handling code here:
        RadioButton_448bit.setSelected(true);
        RadioButton_256bit.setSelected(false);

       
}//GEN-LAST:event_RadioButton_448bitActionPerformed

    private void RadioButton_256bitActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_RadioButton_256bitActionPerformed
        // TODO add your handling code here:
        RadioButton_256bit.setSelected(true);
        RadioButton_448bit.setSelected(false);
         
        
      
}//GEN-LAST:event_RadioButton_256bitActionPerformed

    private void nextEncryptButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_nextEncryptButtonActionPerformed
        // TODO add your handling code here:
       //  boolean encryptpombit = false,encryptpersonbit = false;
        if(RadioButton_256bit.isSelected()==true)
        {
           encryptpersonbit=true;
        }
        if(RadioButton_448bit.isSelected()==true)
        {
           encryptpombit=true;
        }
          SettingsXml setting=new SettingsXml();
          setting.setEncyptPom(encryptpombit);
          setting.setEncryptPersonal(encryptpersonbit);
       // new User().ConfigureSettings(encryptpombit,encryptpersonbit);
         this.dispose();
         new Config_3_backup(new javax.swing.JFrame(), true).setVisible(true);

}//GEN-LAST:event_nextEncryptButtonActionPerformed

    private void backEncryptButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_backEncryptButtonActionPerformed
        // TODO add your handling code here:
        SettingsXml setting=new SettingsXml();
        Config_1_login cl=new Config_1_login(new javax.swing.JFrame(), true);
        cl.text_Email.setText(Config_1_login.username);
          
        if(setting.getRememberPass()==true){           
            cl.Text_Password.setText(Config_1_login.pass);          
              }
          this.dispose();
         cl.setVisible(true);    
        
}//GEN-LAST:event_backEncryptButtonActionPerformed

    private void cancelEncryptButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelEncryptButtonActionPerformed
        // TODO add your handling code here:
             this.dispose();
    }//GEN-LAST:event_cancelEncryptButtonActionPerformed

    /**
    * @param args the command line arguments
    */
//    public static void main(String args[]) {
//        java.awt.EventQueue.invokeLater(new Runnable() {
//            public void run() {
//                Config_2_setting dialog = new Config_2_setting(new javax.swing.JFrame(), true);
//                dialog.addWindowListener(new java.awt.event.WindowAdapter() {
//                    @Override
//                    public void windowClosing(java.awt.event.WindowEvent e) {
//                        System.exit(0);
//                    }
//                });
//                dialog.setVisible(true);
//            }
//        });
//    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    public javax.swing.JRadioButton RadioButton_256bit;
    public javax.swing.JRadioButton RadioButton_448bit;
    private javax.swing.JButton backEncryptButton;
    private javax.swing.JButton cancelEncryptButton;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JLabel label2;
    private javax.swing.JLabel label_Logo;
    private javax.swing.JLabel label_image;
    private javax.swing.JButton nextEncryptButton;
    // End of variables declaration//GEN-END:variables

}
